import store from '@store'

function hasPremission(permissions, value) {
    const all_permission = '*:*:*'
    // if (permissions) {
        const hasPermissions = permissions.some((permission) => {
            return all_permission === permission || value === permission
        })
        return hasPermissions
    // }
}

function index(authMap = {}) {
    const permissions = store.getters && store.getters.permissions
    let map = {}
    for (let x in authMap) {
        map[x] = hasPremission(permissions, authMap[x])
    }
    return map
}

export default index
